﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LeagueOfRila.View;
using LeagueOfRila.Controller;
using Data.Characters;
using Data;
using System.Threading;
using LeagueOfRila.Callback;

namespace LeagueOfRila.Model
{
    public class MenuCharacterChoiceModel : BaseModel
    {
        public int selectedCharacter = 0;
        public static bool is_hover_right = false;
        public static bool is_hover_left = false;
        public List<Character> listCharacter = new List<Character> { new Mage(), new Matthieu(), new Priest(), new War() };
        public Object isLock = new Object();
        public bool lockMenu = false;

        public MenuCharacterChoiceModel()
        {
        }

        public void displayHoverLeft()
        {
            Thread thread = new Thread(() => {
                lock(isLock){is_hover_left = true;}
                Thread.Sleep(200);
                lock (isLock) { is_hover_left = false; }
            });
            thread.Start();
        }
        public void displayHoverRight()
        {
            Thread thread = new Thread(() =>
            {
                lock (isLock) { is_hover_right = true; }
                Thread.Sleep(200);
                lock (isLock) { is_hover_right = false; }
            });
            thread.Start();
        }

        public bool GetHoverLeft()
        {
            return is_hover_left;
        }

        public bool GetHoverRight()
        {
            return is_hover_right;
        }

        public void PlayerReady(string pseudo,string name)
        {
            //Client.cFightService = new CFightService(this);
            //Client.cFightService.mccm = this;
            CGameService cGameService = new CGameService();
            cGameService.mccm = this;
            Services.GetGameService(cGameService).setReadyPlayer(pseudo, name);
        }

        public MenuCharacterChoiceController GetController()
        {
            return this.controller as MenuCharacterChoiceController;
        }

        public void startGame()
        {
            this.GetController().startGame();
        }
    }
}
